﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace UAC.Operation
{
    public class OperationDef
    {
        public int ID { get; set; }
        public int DocumentDefID { get; set; }
        public int OperationDefID { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }

        private int ocid = -1;
        /// <summary>
        /// OperateControl ID
        /// </summary>
        public int OCID { get { return ocid; } set { ocid = value; } }

        public OperationDef() { }

        public OperationDef(DataRow dr)
        {
            this.ID = Convert.ToInt32(dr["id"]);
            this.DocumentDefID = Convert.ToInt32(dr["documentdefid"]);
            this.OperationDefID = Convert.ToInt32(dr["operationdefid"]);
            this.Name = dr["name"].ToString();
            this.Description = dr["description"].ToString();
            if (dr["ocid"] == DBNull.Value)
                this.OCID = -1;
            else
                this.OCID = Convert.ToInt32(dr["ocid"]);
        }

        public override string ToString()
        {
            return string.Format("{0}-{1}", this.DocumentDefID, this.Name);
        }
    }
}
